#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "interface/uiinterface.h"

#include "fclient/fclient.h"

#include "log/log.h"


int main(int argc, char *argv[])
{
   // qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
    initLog();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;

   engine.rootContext()->setContextProperty("ui",UIINTERFACE);


   const QUrl url(QStringLiteral("qrc:/qml/main.qml"));
   QObject::connect(
       &engine,
       &QQmlApplicationEngine::objectCreated,
       &app,
       [url](QObject *obj, const QUrl &objUrl) {
           if (!obj && url == objUrl)
               QCoreApplication::exit(-1);
       },
       Qt::QueuedConnection);
   engine.load(url);
    pthread_t threads[2];
    int thread_ids[2] = {0, 1};
    if(pthread_create(&threads[0], nullptr, &FClient::start, &thread_ids[0]) != 0) {
       // LOG_ERROR("pthread_create error");
    }
    return app.exec();
}
